package gjtx3;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class ListMethod {
    public static void main(String[] args) {
        List list=new ArrayList();
        list.add(111);
        list.add(12.4);
        list.add(-12);
        list.add("aaa");
        list.add('b');
        list.add('b');
        System.out.println(list);
        list.add(2,"abc");
        System.out.println(list);
        List list1=new ArrayList();
        list1.add(555);
        list1.add("sss");
        list1.add("mmm");
        list.addAll(list1);
        System.out.println(list);
        list.addAll(1,list1);
        System.out.println(list);
        System.out.println(list.isEmpty());//false
        list.clear();
        System.out.println(list.isEmpty());//true
        System.out.println(list);
        list.addAll(list1);
        String a="jjj";
        int b=555;
        System.out.println(list.contains(a));
        System.out.println(list.contains(b));
        list.add("rrr");
        list.containsAll(list1);
        System.out.println(list.containsAll(list1));
        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
        list.equals(b);
        System.out.println(list);
        System.out.println(list.equals(555));
        System.out.println(list.get(0).equals(b));
        System.out.println(list.hashCode());
        System.out.println(list.indexOf("nnn"));
        System.out.println(list.indexOf("mmm"));
        Iterator ir=list.iterator();
        for (Object s:list)
            System.out.print(ir.next()+" ");
        System.out.println("");
        ListIterator is=list.listIterator();
        for (Object s:list)
            System.out.print(is.next()+" ");
        System.out.println("");
       list.addAll(list1);
       list.remove(list.get(0));
        System.out.println(list);
        list.set(1,"uuu");
        System.out.println(list);
        System.out.println(list.size());
        System.out.println(list.subList(2,5));
        list.clear();
        list.add(111);
        list.add(222);
        list.add(333);
        list.add(444);
        Object[] h=list.toArray();
        for (Object s:h)
        System.out.println(s);
        //System.out.println(list.toArray((int[1],));
    }
}
